﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace CoreSolution.Tools.Extensions
{
   public static class ReflectExtenisons
    {
        /// <summary>
        /// 特性
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static PropertyInfo[] GetProperties(this object obj)
        {
            return obj.GetType().GetProperties().ToArray();
        }


        /// <summary>
        /// 特性
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static void SetValues(this object obj,string key,object value)
        {
            var PreopertyArr=GetProperties(obj);
            foreach(var item in PreopertyArr)
            {
                //item.Name
                if(item.Name.ToUpper()==key.ToUpper())
                item.SetValue(obj, value);
            }
        }

    }
}
